<script>
    <#if formField.readonly?? && formField.readonly=="1">
    <#else>
	    <#if showFileStorage?default('false') == "false">
	    $(document).ready(function(){
	        $('#uploadify${field.name}').uploadify({
	            'basepath'       : TDQS.CONTEXT_PATH,
	            'queueID'        : "fieldMap['${field.name}'].fileQueue",
	            'fileDesc' :  '请选择文件',
	            'sizeLimit' :1024*1024*100,
	            'fileExt' :'*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.zip;*.rar;*.jpg;*.jpeg;*.gif;*.png;*.bmp;*.DWG;*.psd;*.dws;*.dxf;*.dwt;*.ppt;*.pptx;*.mmp;*.vsd;*.tif;*.tif',
	            'onSelect' : function(){
	            	$('.button','.buttonBox').attr('disabled','disabled');
	            },
	            'onCancel' : function(){
	            	$('.button','.buttonBox').attr('disabled',false);
	            },
	            'onComplete' : function(event, ID, fileObj, response, data){
	            	$('.button','.buttonBox').attr('disabled',false);
	                $(document.getElementById("${field.name}.attachment")).val(unescape(response));
	                if($(document.getElementById("${field.name}.fileForValidateValue")).val()=='') {
	                    $(document.getElementById("${field.name}.fileForValidateValue")).val($(document.getElementById("${field.name}.attachment")).val());
	                }
	            },
	            'onCancelCompleted' : function(){
	            	$('.button','.buttonBox').attr('disabled',false);
	                var arr = $('.uploadifyQueueItem',$(document.getElementById('${field.name}NodeTable')));
	                var fileArr = $('.uploadedFile',$(document.getElementById('${field.name}NodeTable')));
	                if(arr.length==0 && fileArr.length==0) {
	                    $(document.getElementById("${field.name}.attachment")).val('');
	                    if($(document.getElementById("${field.name}.fileStorageValue")).val()=='') {
	                        $(document.getElementById("${field.name}.fileForValidateValue")).val('');
	                    }
	                }
	            },
	            'onError' : function(){
	            	$('.button','.buttonBox').attr('disabled',false);
	            },
	            'onFileSizeError' : function(){
	            	$('.button','.buttonBox').attr('disabled',false);
	            }
	        });
	    });
	
	    function deleteAttachment${field.name}(index) {
	        jConfirm('确认要删除附件吗？', '确认对话框 ', function(r) {
	            if(r){
	                $(document.getElementById('fileInfo${field.name}'+index)).remove();
	                var arr = $('.uploadifyQueueItem',$(document.getElementById('${field.name}NodeTable')));
	                var fileArr = $('.uploadedFile',$(document.getElementById('${field.name}NodeTable')));
	                if(arr.length==0 && fileArr.length==0) {
	                    $(document.getElementById("${field.name}.attachment")).val('');
	                    if($(document.getElementById("${field.name}.fileStorageValue")).val()=='') {
	                        $(document.getElementById("${field.name}.fileForValidateValue")).val('');
	                    }
	                }
	            }else{
	                return false;
	            }
	        });
	    }
	    </#if>

    function copyPlanTime${field.name}() {
        $(document.getElementById("${field.name}.planTimevalue")).val($(document.getElementById("${field.name}.planTime")).val());
    }

    function copyActualTime${field.name}() {
        $(document.getElementById("${field.name}.actualTimevalue")).val($(document.getElementById("${field.name}.actualTime")).val());
    }

    <#if showExpireDate?default('false') == "true">
    function copyExpirationDate${field.name}() {
        $(document.getElementById("${field.name}.expirationDatevalue")).val($(document.getElementById("${field.name}expirationDate")).val());
    }
    </#if>

    function copyCode${field.name}() {
        $(document.getElementById("${field.name}.codevalue")).val($(document.getElementById("${field.name}.code")).val());
    }

    function copyFileStorage${field.name}() {
        $(document.getElementById("${field.name}.fileStorageValue")).val($(document.getElementById("${field.name}.fileStorage")).val());
        if($(document.getElementById("${field.name}.fileForValidateValue")).val()=='') {
            $(document.getElementById("${field.name}.fileForValidateValue")).val($(document.getElementById("${field.name}.fileStorage")).val());
        }
        if(document.getElementById("${field.name}.attachment") && document.getElementById("${field.name}.fileStorageValue")) {
	        if($(document.getElementById("${field.name}.fileStorageValue")).val()=='' && $(document.getElementById("${field.name}.attachment")).val()=='') {
	            $(document.getElementById("${field.name}.fileForValidateValue")).val('');
	        }
        } else if(document.getElementById("${field.name}.attachment")){
        	if($(document.getElementById("${field.name}.attachment")).val()=='') {
	            $(document.getElementById("${field.name}.fileForValidateValue")).val('');
	        }
        } else if(document.getElementById("${field.name}.fileStorageValue")){
        	if($(document.getElementById("${field.name}.fileStorageValue")).val()=='') {
	            $(document.getElementById("${field.name}.fileForValidateValue")).val('');
	        }
        }
    }
    </#if>

	<#if showFileStorage?default('false') == "false">
    function downloadAttachment${field.name}(attachmentId) {
        var url = TDQS.CONTEXT_PATH+"/download/downLoadAttachment?attachmentId="+attachmentId+"&date="+new Date().toLocaleString();
        //window.open(url);
        var frame = document.createElement("iframe");
        frame.src = url;
        frame.style.display = "none";
        document.body.appendChild(frame);
    }

    function viewAttachment${field.name}(attachmentId) {
        var url = TDQS.CONTEXT_PATH+"/download/viewAttachment?attachmentId="+attachmentId+"&instanceId=<#if businessInstanceField?? && businessInstanceField.instance?? && businessInstanceField.instance.id??>${businessInstanceField.instance.id}</#if>&date="+new Date().toLocaleString();
        window.open(url);
    }
    </#if>
</script>

<#if formField.hidden?? && formField.hidden=="1">
<input type="hidden" name="fieldMap['${field.name}'].node.id" value="<#if businessInstanceField?? && businessInstanceField.node??>${businessInstanceField.node.id?default('')}</#if>">
<input type="hidden" name="fieldMap['${field.name}'].entityId" value="<#if businessInstanceField?? && businessInstanceField.entityId??>${businessInstanceField.entityId}</#if>">
<input type="hidden" name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">
<input type="hidden" name="fieldMap['${field.name}'].node.planTime" value="<#if businessInstanceField?? && businessInstanceField.node??>${businessInstanceField.node.planTime?default('')}</#if>">
<input type="hidden" name="fieldMap['${field.name}'].node.actualTime" value="<#if businessInstanceField?? && businessInstanceField.node??>${businessInstanceField.node.actualTime?default('')}</#if>">
<input type="hidden" name="fieldMap['${field.name}'].node.code" value="<#if businessInstanceField?? && businessInstanceField.node??>${businessInstanceField.node.code?default('')}</#if>">
<input type="hidden" name="fieldMap['${field.name}'].node.attachment" value="<#if businessInstanceField?? && businessInstanceField.node??>${businessInstanceField.node.attachment?default('')}</#if>">
<#else>

<#-- 定义宏，输出必填红星号 -->
    <#macro renderMandatory param="true">
        <#if (!formField.readonly?? || formField.readonly=="0") && param=="true">
        <span></span>
        </#if>
    </#macro>

<table cellspacing="0" id="${field.name}NodeTable" cellpadding="0" class="listviewTable_attach" width="100%">
    <input type="hidden" name="fieldMap['${field.name}'].node.id" value="<#if businessInstanceField?? && businessInstanceField.entityId??>${businessInstanceField.entityId}</#if>">
    <input type="hidden" name="fieldMap['${field.name}'].entityId" value="<#if businessInstanceField?? && businessInstanceField.entityId??>${businessInstanceField.entityId}</#if>">
    <input type="hidden" name="fieldMap['${field.name}'].field.id"  value="${formField.field.id}">
    <#if showFieldName?default('true') != 'false'>
        <tr class="listviewHeader">
            <td colspan="6" align="left">
            ${field.displayName?default(field.desc)}
            </td>
        </tr>
    </#if>
<tr class="listviewTR">
    <td class="listviewTD" style="text-align:right; width:8%;"><@renderMandatory param=validatePlanDate?default('false')/>计划时间: </td>
    <td  class="listviewContent" style="width:25%" >
        <#if formField.readonly?? && formField.readonly=="1">
            <#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.planTime??>${businessInstanceField.entity.planTime?string("yyyy-MM-dd")}</#if>
            <input type="hidden" id="${field.name}.planTime" name="fieldMap['${field.name}'].node.planTime" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.planTime??>${businessInstanceField.entity.planTime?string("yyyy-MM-dd")}</#if>"> </input>
        <#else>
            <input type="text" id="${field.name}.planTime" name="fieldMap['${field.name}'].node.planTime" onblur="copyPlanTime${field.name}()" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.planTime??>${businessInstanceField.entity.planTime?string("yyyy-MM-dd")}</#if>" style="width:173px;"   class="Wdate" onfocus="WdatePicker();"> </input>
            <input type="hidden" id="${field.name}.planTimevalue" name="fieldMap['${field.name}.planTime'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.planTime??>${businessInstanceField.entity.planTime?string("yyyy-MM-dd")}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.planTime']?? && businessInstanceField.instance.fieldMap[field.name+'.planTime'].value??>${businessInstanceField.instance.fieldMap[field.name+'.planTime'].value}</#if></#if>"/>
        </#if>
    </td>
    <td class="listviewTD"  style="width:8%;text-align:right;"><@renderMandatory param=showredActualtime?default('true')/>实际时间:</td>
    <td class="listviewContent" style="width:173px;"  <#if showFileCode?default('true') != "true">colspan=3</#if>>
        <#if (formField.readonly?? && formField.readonly=="1")>
            <#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.actualTime??>
                ${businessInstanceField.entity.actualTime?string("yyyy-MM-dd")}
            </#if>
            <input type="hidden" id="${field.name}.actualTime" name="fieldMap['${field.name}'].node.actualTime" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.actualTime??>${businessInstanceField.entity.actualTime?string("yyyy-MM-dd")}</#if>" > </input>
        <#else>
            <input type="text" id="${field.name}.actualTime" name="fieldMap['${field.name}'].node.actualTime" onblur="copyActualTime${field.name}()" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.actualTime??>${businessInstanceField.entity.actualTime?string("yyyy-MM-dd")}</#if>" style="width:173px;" class="Wdate" onfocus="WdatePicker();"> </input>
            <input type="hidden" id="${field.name}.actualTimevalue" name="fieldMap['${field.name}.actualTime'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.actualTime??>${businessInstanceField.entity.actualTime?string("yyyy-MM-dd")}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.actualTime']?? && businessInstanceField.instance.fieldMap[field.name+'.actualTime'].value??>${businessInstanceField.instance.fieldMap[field.name+'.actualTime'].value}</#if></#if>"/>
        </#if>
    </td>
    <#if showFileCode?default('true') == "true">
        <td class="listviewTD" style="text-align:right; width:8%;"><@renderMandatory param=validateFileCode?default('false')/>文号: </td>
        <td  class="listviewContent" style="width:25%" >
            <#if formField.readonly?? && formField.readonly=="1">
                <#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.safeCode?default('')}</#if>
                <input  type="hidden" id="${field.name}.code" name="fieldMap['${field.name}'].node.code" value="<#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.code?default('')}</#if>" ></input>
            <#else>
                <input datarule="string" datarulejson='{"displayName":"${field.displayName}文号","dataType":"string","length":"20"}' type="text" id="${field.name}.code" name="fieldMap['${field.name}'].node.code" onblur="copyCode${field.name}()"  value="<#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.code?default('')}</#if>" style="width:130px"></input>
                <input type="hidden" id="${field.name}.codevalue" name="fieldMap['${field.name}.code'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.code??>${businessInstanceField.entity.code}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.code']?? && businessInstanceField.instance.fieldMap[field.name+'.code'].value??>${businessInstanceField.instance.fieldMap[field.name+'.code'].value}</#if></#if>"/>
            </#if>
        </td>
    </#if>
    </tr>
    <tr class="listviewTR">
    <#if showExpireDate?default('false') == "true">
        <td class="listviewTD"  style="width:8%;text-align:right;" >有效截止时间:</td>
        <td class="listviewContent" colspan="5">
            <#if formField.readonly?? && formField.readonly=="1">
                <#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.expirationDate??>${businessInstanceField.entity.expirationDate?string("yyyy-MM-dd")}</#if>
                <input type="hidden" id="${field.name}expirationDate" name="fieldMap['${field.name}'].node.expirationDate" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.expirationDate??>${businessInstanceField.entity.expirationDate?string("yyyy-MM-dd")}</#if>" > </input>
            <#else>
                <input type="text" id="${field.name}expirationDate" name="fieldMap['${field.name}'].node.expirationDate" onblur="copyExpirationDate${field.name}()" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.expirationDate??>${businessInstanceField.entity.expirationDate?string("yyyy-MM-dd")}</#if>" style="width:173px;" class="Wdate" onfocus="WdatePicker();"> </input>
                <input type="hidden" id="${field.name}.expirationDatevalue" name="fieldMap['${field.name}.expirationDate'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.expirationDate??>${businessInstanceField.entity.expirationDate?string("yyyy-MM-dd")}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.expirationDate']?? && businessInstanceField.instance.fieldMap[field.name+'.expirationDate'].value??>${businessInstanceField.instance.fieldMap[field.name+'.expirationDate'].value}</#if></#if>"/>
            </#if>
        </td>
    </#if>
</tr>
    <#if showFileStorage?default('false') == "true">
        <tr class="listviewTR">
            <td class="listviewTD"  style="width:8%;text-align:right;"><@renderMandatory param=showredCcsm?default('true')/>存储说明:</td>
            <td class="listviewContent" colspan="5">
                <#if formField.readonly?? && formField.readonly=="1">
                    <#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.safeFileStorage?default('')}</#if>
                    <input  type="hidden" id="${field.name}.fileStorage" name="fieldMap['${field.name}'].node.fileStorage" value="<#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.fileStorage?default('')}</#if>" ></input>
                <#else>
                    <textarea datarule="string" datarulejson='{"displayName":"${field.displayName}存储说明","dataType":"string","length":"1000"}' id="${field.name}.fileStorage" name="fieldMap['${field.name}'].node.fileStorage" onblur="copyFileStorage${field.name}()"  style="width:65%"><#if businessInstanceField?? && businessInstanceField.entity??>${businessInstanceField.entity.fileStorage?default('')}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.fileStorage']?? && businessInstanceField.instance.fieldMap[field.name+'.fileStorage'].value??>${businessInstanceField.instance.fieldMap[field.name+'.fileStorage'].value}</#if></#if></textarea>
                    <input type="hidden" id="${field.name}.fileStorageValue" name="fieldMap['${field.name}.fileStorage'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.fileStorage??>${businessInstanceField.entity.fileStorage}</#if>"/>
                    <input type="hidden" id="${field.name}.fileForValidateValue" name="fieldMap['${field.name}.fileForValidate'].value" value="<#if businessInstanceField?? && businessInstanceField.entity?? && businessInstanceField.entity.fileForValidate??>${businessInstanceField.entity.fileForValidate}<#else><#if businessInstanceField.instance.fieldMap[field.name+'.fileForValidate']?? && businessInstanceField.instance.fieldMap[field.name+'.fileForValidate'].value??>${businessInstanceField.instance.fieldMap[field.name+'.fileForValidate'].value}</#if></#if>"/>
                </#if>
            </td>
        </tr>
    </#if>
    <#if showFileStorage?default('false') == "false">
    <tr class="listviewTR">
        <td class="listviewTD"  style="width:8%;text-align:right;"><#if showFileStorage?default('false') != "true"><@renderMandatory  param=showreddzwj?default('true')/></#if>电子文件:</td>
        <td class="listviewContent" colspan="5" >
            <#if fileinfo_list?? && fileinfo_list?size gt 0>
                <#assign index = 0>
                <#list fileinfo_list as fileinfo>
                    <div id="fileInfo${field.name}${fileinfo.fileId}" class="uploadedFile">
                        <input type=hidden name="fieldMap['${field.name}'].oldFileQueue[${index}].fileId" value="${fileinfo.fileId}">
                        <div style="position:relative;+position:static;_position:static;float:left;clear:left">
								<span class="fileName">
									<div style="width:650px">
                                        <div style="position:relative;+position:static;_position:static;float:left;clear:left;padding:2px;width:20px">
                                            <img border="0" src="/PNPMS/script/plugins/Uploadify/global.jpg" class="statusimg">
                                        </div>
                                        <div style="position:relative;+position:static;_position:static;float:left;width:500px">
                                            &nbsp;[${fileinfo.dateTime?string('yyyy-MM-dd')}]&nbsp;&nbsp;<a href="javascript:void(0);" onclick="downloadAttachment${field.name}('${fileinfo.fileId}');return false;">${fileinfo.realName?default('')}</a>
                                            <#if fileinfo.ext?? && (fileinfo.ext=='doc' || fileinfo.ext=='DOC' || fileinfo.ext=='docx' || fileinfo.ext=='DOCX' || fileinfo.ext=='xls' || fileinfo.ext=='XLS' || fileinfo.ext=='xlsx' || fileinfo.ext=='XLSX' || fileinfo.ext=='pdf' || fileinfo.ext=='PDF' || fileinfo.ext=='jpg' || fileinfo.ext=='JPG' || fileinfo.ext=='jpeg' || fileinfo.ext=='JPEG' || fileinfo.ext=='bmp' || fileinfo.ext=='BMP' || fileinfo.ext=='png' || fileinfo.ext=='PNG' || fileinfo.ext=='gif' || fileinfo.ext=='GIF' || fileinfo.ext=='tif' || fileinfo.ext=='TIF' || fileinfo.ext=='ppt' || fileinfo.ext=='PPT' || fileinfo.ext=='pptx' || fileinfo.ext=='PPTX')>
                                                &nbsp;<a href="javascript:void(0);" onclick="viewAttachment${field.name}('${fileinfo.fileId}');return false;">预览</a>
                                            </#if>
                                        </div>
                                        <div style="position:relative;+position:static;_position:static;float:left;width:20px" class="cancel">
                                            <#if !formField.readonly?? || formField.readonly=="0">
                                                <a href="javascript:void(0);" onclick="deleteAttachment${field.name}('${fileinfo.fileId}');return false;"><img border="0" src="/PNPMS/theme/default/images/main/delete.png"/></a>
                                            </#if>
                                        </div>
                                    </div>
								</span>
                        </div>
                    </div>
                    <#assign index = index+1>
                </#list>
            </#if>

            <#if formField.readonly?? && formField.readonly=="1">
            <#else>
                <div style="width:70%" id="fieldMap['${field.name}'].fileQueue" >
                    <#assign index=1>
                    <#if businessInstanceField?? && businessInstanceField.fileQueue??>
                        <#list  businessInstanceField.fileQueue as fileInfo>
                            <#if fileInfo?? && fileInfo.realName??>
                                <div id="uploadify${field.name}newfile${index}" class="uploadifyQueueItem completed" style="width:650px">
                                    <div style="width:520px;clear:left;float:left">
								<span class="fileName">
									<img class="statusimg" border="0" src="/PNPMS/script/plugins/Uploadify/global.jpg">
									&nbsp;${fileInfo.realName?default('')}(${fileInfo.fileSize?default('')})
								</span>
                                        <span class="percentage"></span>
                                    </div>
                                    <div class="cancel" style="padding:2px;float:left;width:20px">
                                        <a href="javascript:jQuery('#uploadify${field.name}').uploadifyCancel('newfile${index}')">
                                            <img border="0" src="/PNPMS/theme/default/images/main/delete.png">
                                        </a>
                                    </div>
                                    <input id="uploadify${field.name}newfile${index}hidvalue" type="hidden" value='{"aliasName":null,"company":null,"dateTime":null,"ext":null,"fileData":null,"fileId":null,"fileType":null,"length":0,"node":null,"fileSize":"<#if fileInfo.fileSize??>${fileInfo.fileSize}</#if>","realName":"<#if fileInfo?? && fileInfo.realName??>${fileInfo.realName}</#if>","realPath":"<#if fileInfo.realPath??>${fileInfo.realPath?replace('\\','/')}"}</#if>' name="fieldMap['${field.name}'].fileQueue">
                                </div>
                                <#assign index=index + 1>
                            </#if>
                        </#list>
                    </#if>
                </div>
            </#if>

            <#if formField.readonly?? && formField.readonly=="1">
                &nbsp;
            <#else>
                <div style="clear:both"><input type="hidden" id="${field.name}.attachment" name="fieldMap['${field.name}.attachment'].fileQueue" <#if (businessInstanceField.fileQueue?? && businessInstanceField.fileQueue?size gt 0) || (fileinfo_list?? && fileinfo_list?size gt 0)>value='{"aliasName":null,"company":null,"dateTime":null,"ext":null,"fileData":null,"fileId":null,"fileType":null,"length":0,"node":null,"fileSize":"","realName":"","realPath":""}'</#if>>
                
             
                 <#if templeteInstance?? && isDownLoadTemplete??>
<table cellspacing="0" cellpadding="0" style="border:0px;"><tr><td style="border:0px;">
		       <input type="file" name="uploadify${field.name}" id="uploadify${field.name}" />
				</td><td style="border:0px;">
				<a href="#" class="button" tabindex="-1"><input type="button" onclick="downLoadFunction('${templeteInstance}','download/downLoad');return false;" value="下载模板"></a>
				</td></tr></table>
				
<#else>	
       <input type="file" name="uploadify${field.name}" id="uploadify${field.name}" />
</#if>
                
                
                
                </div>
            </#if>
        </td>
    </tr>
    </#if>
</table>
</#if>